<?php
class OrderPayAction extends CommonAction {
	
	function _initialize(){
		parent::_initialize();
	}
	
    function index(){
    	$order_number = $this->_param('order_number', 'trim');
    	$map = array();
    	if($order_number)
    		$map['order_number'] = $order_number;
    	
    	$model = D('OrderPay');
    	$count = $model->where($map)->count('id');

    	if ($count > 0) {
    		import("ORG.Util.Page");
    		
    		//分页查询数据
    		$p = new Page($count, 20);
    		$voList = $model->where($map)->relation(true)->order("`id` desc")->limit($p->firstRow . ',' . $p->listRows)->select();

    		//分页跳转的时候保证查询条件
    		foreach ($map as $key => $val) {
    			if (!is_array($val)) {
    				$p->parameter .= "$key=" . urlencode($val) . "&";
    			}
    		}
    		
    		//分页显示
    		$page = $p->show();
    		//模板赋值显示
    		$this->assign('status_arr', $model->get_status_arr());
    		$this->assign('list', $voList);
    		$this->assign("page", $page);
    	}
    	cookie('_currentUrl_', __SELF__);
    	$this->display();
    }
    
    function confirm(){
    	$id = $this->_param('id', 'trim');
    	$model = D('OrderPay');
    	$data = array('status' => 1, 'oper_user' => session('login_user_id'));
    	$result = $model->where("id='$id'")->save($data);

    	if($result)
    		$this->success('处理成功');
    	else
    		$this->error('处理失败！');
    }
    
    function delete(){
    	$id = $this->_request('id');
    	 
    	if($id == '')
    		$this->error('参数错误!');
    	 
    	$model = D('Article');
    	$flag = $model->delete($id);
    	
    	if(!$flag)
    		$this->error('删除失败!');
    	else
    		$this->success('删除成功!',cookie('_currentUrl_'));
    	
    }
    
    
}